package net.siufung.market.base.permit.enums;

import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.Setter;
import net.siufung.core.model.EnumsVo;

import java.util.List;

/**
 * @author 陈建峰
 * @since 2021/11/30 11:25 上午
 */
public enum KeepAliveTypes {

    /**
     * 缓存
     */
    NOT(false, "缓存"),
    /**
     * 不缓存
     */
    IS(true, "不缓存");

    @Getter
    @Setter
    private Boolean value;

    @Getter
    @Setter
    private String desc;

    KeepAliveTypes(Boolean value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static KeepAliveTypes get(Boolean value) {
        KeepAliveTypes[] menuKeepAlive = values();
        for (KeepAliveTypes keepAlive : menuKeepAlive) {
            if (keepAlive.getValue().equals(value)) {
                return keepAlive;
            }
        }
        return null;
    }

    public static String getDesc(Boolean value) {
        KeepAliveTypes[] menuKeepAlive = values();
        for (KeepAliveTypes keepAlive : menuKeepAlive) {
            if (keepAlive.getValue().equals(value)) {
                return keepAlive.getDesc();
            }
        }
        return null;
    }

    public static List<EnumsVo> getList(){
        List<EnumsVo> enumsVoList = Lists.newLinkedList();
        EnumsVo enumsVO = null;
        for (KeepAliveTypes menuKeepAlive: values()) {
            enumsVO = new EnumsVo();
            enumsVO.setValue(menuKeepAlive.getValue());
            enumsVO.setDesc(menuKeepAlive.getDesc());
            enumsVoList.add(enumsVO);
        }
        return enumsVoList;
    }
}
